public class Text5 {
    //调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
    //如数组：[1,2,3,4,5,6]
    //调整后可能是：[1, 5, 3, 4, 2, 6]
    public static void main(String[] args) {
        int[] a = {1,2,3,4,5,6};
        int head = 0;
        int end = a.length - 1;
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }

        System.out.println();

        while(head < end) {
            while(head < end && a[head] % 2 != 0) {
                head++;
            }
            while(head < end && a[end] % 2 == 0) {
                end--;
            }
            int tmp = a[head];
            a[head] = a[end];
            a[end] = tmp;
        }

        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }
    }
}
